/**
 * JpushSender.java 
 * Copyright © 2009-2014, Liu Tao
 * 
 * @author Liu Tao
 * @create 2014年5月22日
 */
package com.pshare.sender;

import java.util.List;

import org.apache.log4j.Logger;
//import cn.jpush.api.JPushClient;
//import cn.jpush.api.common.APIConnectionException;
//import cn.jpush.api.common.APIRequestException;
//import cn.jpush.api.push.PushResult;
//import cn.jpush.api.push.model.Message;
//import cn.jpush.api.push.model.Platform;
//import cn.jpush.api.push.model.PushPayload;
//import cn.jpush.api.push.model.audience.Audience;
//import cn.jpush.api.push.model.notification.Notification;

/**
 * 极光推送
 */
public class JpushSender extends PushSender {

	private static final Logger logger = Logger.getLogger(JpushSender.class);
	private static int SENDNO = 1;
	
	public JpushSender() {
	}

	public JpushSender(String androidAppKey, String androidMasterSecret) {
		this.androidAppKey = androidAppKey;
		this.androidMasterSecret = androidMasterSecret;
	}

	@Override
	public void doPush(Integer type, List<String> registrationIds, String title, String message, String objId, Integer msgType, String sound) {
//		try {
//			JPushClient jpushClient = new JPushClient(androidMasterSecret, androidAppKey, 3);
//
//			PushPayload payload = PushPayload
//				.newBuilder()
//				.setPlatform(Platform.android())
//				.setAudience(Audience.registrationId(registrationIds.toArray(new String[0])))
//				.setNotification(Notification.alert(message))
//				.setMessage(Message.newBuilder().setMsgContent(message).addExtra("content_type", msgType).addExtra("obj_id", objId).build())
//				.build();
//
//			try {
//				PushResult result = jpushClient.sendPush(payload);
//			} catch (APIConnectionException | APIRequestException e) {
//				logger.error(e.getMessage(), e);
//			}
//				
//			synchronized(JpushSender.class) {
//				SENDNO++;
//				if(SENDNO > Integer.MAX_VALUE) {
//					SENDNO = 1;
//				}
//			}
//				
//			for(String reg : registrationIds) {
//				logger.info(reg);
//			}
//		} catch (Exception e) {
//			logger.error(e.getMessage(), e);
//		}
	}

}
